Ext.require(['AM.service.Setting', 'AM.util.URL']);


Ext.define("AM.component.menu.MenuItemFactory", {


    singleton:true,


    rotate:function () {
        return {
            text:'旋转',
            menu:[
                {
                    xtype:'slider',
                    value:0,
                    increment:1,
                    minValue:0,
                    maxValue:360,
                    listeners:{
                        'change':function (slider, newValue) {
                            AM.service.Setting.rotate(newValue);
                        }
                    }
                }


            ]
        };
    },

    play:function () {
        return {
            text:'播放',
            handler:function () {
                var dom = ppt.cache.rightClickDom;
                dom.play();
            }
        }
    },

    pause:function () {
        return {
            text:'暂停',
            handler:function () {
                var dom = ppt.cache.rightClickDom;
                dom.pause();
            }
        }
    },


    backgroundColor:function () {
        var tempBtn = Ext.DomHelper.createDom({
            tag:'input',
            type:'color',
            style:{
                'border-style':'none',
                width:0,
                height:0
            }
        });
        document.body.appendChild(tempBtn);
        tempBtn.onchange = function(){
             AM.service.Setting.backgroundColor(tempBtn.value)
        }
        return {
            text:'背景颜色',
            handler:function () {
                tempBtn.click();
            }
        };
    },

    backgroundImage:function () {
        return {
            text:'背景图片',
            handler:function () {
                Ext.create('AM.picker.Image', {doClickItem:function (name) {
                    var dom = ppt.cache.rightClickDom;
                    dom.style.backgroundImage = 'url(' + AM.util.URL.image + name + ')';
                }});
            }
        }
    },


    scale:function () {
        return {
            text:'放大缩小',
            menu:[
                {
                    xtype:'slider',
                    value:5,
                    increment:1,
                    minValue:1,
                    maxValue:10,
                    listeners:{
                        'change':function (slider, newValue) {
                            AM.service.Setting.scale(newValue / 5);
                        }
                    }
                }

            ]

        }
    },


    scaleBorder:function () {
        return {
            text:'缩小边框',
            handler:function () {
                AM.service.Setting.scaleBorder();
            }
        }

    },


    opacity:function () {
        return {text:'透明度',
            menu:[
                {
                    xtype:'slider',
                    value:10,
                    increment:1,
                    minValue:1,
                    maxValue:10,
                    listeners:{
                        'change':function (slider, newValue) {
                            AM.service.Setting.opacity(newValue / 10);
                        }
                    }
                }

            ]
        }
    },


    src:function () {
        return {
            text:'设置源',
            handler:function () {
                Ext.Msg.prompt('设置源', '请填写路径, 例如：video/test1.ogg， audio/test1.mp3', function (btn, text) {
                    if (btn == 'ok') {
                        var url = 'http://172.31.4.75:8080/ppt/rs/' + text;
                        AM.service.Setting.src(url);
                    }
                })
            }
        }
    },

    width:function () {
        return {
            text:'宽度',
            menu:[
                {
                    xtype:'slider',
                    value:300,
                    increment:1,
                    minValue:1,
                    maxValue:800,
                    listeners:{
                        'change':function (slider, newValue) {
                            AM.service.Setting.width(newValue);
                        }
                    }
                }

            ]
        }
    },

    height:function () {
        return {
            text:'高度',
            menu:[
                {
                    xtype:'slider',
                    value:300,
                    increment:1,
                    minValue:1,
                    maxValue:800,
                    listeners:{
                        'change':function (slider, newValue) {
                            AM.service.Setting.height(newValue);
                        }
                    }
                }

            ]
        }
    },


    edit:function () {
        return {
            text:'编辑|移动',
            menu:[
                {text:'编辑', handler:function () {
                    AM.service.Setting.disableDrag();
                }},
                {text:'移动', handler:function () {
                    AM.service.Setting.enableDrag();
                }}
            ]
        }
    },


    anim:function () {
        return {
            text:'动画',
            menu:[
                {text:'从左向右移动', handler:function () {
                    AM.service.Setting.anim('leftRight');
                }},
                {text:'从小到大', handler:function () {
                    AM.service.Setting.anim('smallBig');
                }},
                {text:'旋转1', handler:function () {
                    AM.service.Setting.anim('rotate1');
                }},
                {text:'旋转2', handler:function () {
                    AM.service.Setting.anim('rotate2');
                }},
                {text:'旋转3', handler:function () {
                    AM.service.Setting.anim('rotate3');
                }},
                {text:'rotate4', handler:function () {
                    AM.service.Setting.anim('rotate4');
                }},
                {text:'opacity', handler:function () {
                    AM.service.Setting.anim('opacity');
                }}


            ]

        }

    },


    zIndex:function () {
        return {
            text:'图层',
            menu:[
                {
                    xtype:'slider',
                    increment:1,
                    minValue:1,
                    maxValue:9,
                    listeners:{
                        'change':function (slider, newValue) {
                            AM.service.Setting.zIndex(newValue);
                        }
                    }
                }

            ]
        }
    },

    // 切换声音
    cutOverAudio:function () {
        return {
            text:'设置切换声音',
            menu:[
                {
                    text:'水滴声',
                    handler:function () {
                        AM.service.Setting.cutOverAudio('test1.wav');
                    }
                },
                {
                    text:'打火机',
                    handler:function () {
                        AM.service.Setting.cutOverAudio('test2.wav');
                    }
                }


            ]
        }
    },

    delete:function () {
        return {
            text:'删除',
            iconCls:'delete',
            handler:function () {
                AM.service.Setting.delete();
            }
        }
    },

    deletePage:function () {
        return {
            text:'删除此页',
            iconCls:'delete',
            handler:function () {
                AM.service.Setting.deletePage();
            }
        }
    }




})
;